using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy : MonoBehaviour
{
    public int life;
    Animator animator;
    public GameObject coin;
    private void Start()
    {
        animator = GetComponent<Animator>();
    }
    void Update()
    {
        if(life <= 0)
        {
            GameObject.Find("Player").GetComponent<PlayerController2D>().current_exp++;
            if(this.gameObject.name != "boss")
            {
                Destroy(this.gameObject);
                Instantiate(coin, this.gameObject.transform.position, Quaternion.identity);
            }
            
        }
    }

    public void GetHit()
    {
        life -= GameObject.Find("Player").GetComponent<PlayerController2D>().damage;
        this.gameObject.GetComponent<AudioSource>().Play();
        animator.SetTrigger("hit");
    }
}
